<template>
  <el-row :gutter="40" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="12" class="card-panel-col">
      <div class="card-panel" @dblclick="dbclick" @click="handleSetLineChartData('warehousmasys/rukumanage/RukuInfoMain')">
        <!--        <div class="card-panel-icon-wrapper icon-people">-->
        <!--          <svg-icon icon-class="peoples" class-name="card-panel-icon" />-->
        <!--        </div>-->
        <div class="card-panel-icon-wrapper">
          <i class="el-icon-download" style="font-size: 60px;color: #40c9c6"></i>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            今日入库
          </div>
          <count-to :start-val="0" :end-val="syData.jrrk" :duration="2600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="12" class="card-panel-col">
      <div class="card-panel" @dblclick="dbclick" @click="handleSetLineChartData('warehousmasys/chukumanage/chukuinfoMain')">
        <!--        <div class="card-panel-icon-wrapper icon-message">-->
        <!--          <svg-icon icon-class="message" class-name="card-panel-icon" />-->
        <!--        </div>-->
        <div class="card-panel-icon-wrapper">
          <i class="el-icon-upload2" style="font-size: 60px;color: #36a3f7"></i>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            今日出库
          </div>
          <count-to :start-val="0" :end-val="syData.jrck" :duration="3000" class="card-panel-num" />
        </div>
      </div>
    </el-col>
<!--    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">-->
<!--      <div class="card-panel" @dblclick="dbclick" @click="handleSetLineChartData('sale/xsdd/salesorder')">-->
<!--     -->
<!--        <div class="card-panel-icon-wrapper">-->
<!--          <i class="el-icon-edit-outline" style="font-size: 60px;color: #f4516c"></i>-->
<!--        </div>-->
<!--        <div class="card-panel-description">-->
<!--          <div class="card-panel-text">-->
<!--            销售订单-->
<!--          </div>-->
<!--          <count-to :start-val="0" :end-val="syData.jrpc" :duration="3200" class="card-panel-num" />-->
<!--        </div>-->
<!--      </div>-->
<!--    </el-col>-->
<!--    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">-->
<!--      <div class="card-panel" @dblclick="dbclick" @click="handleSetLineChartData('psplan/psjh')">-->
<!--       -->
<!--        <div class="card-panel-icon-wrapper">-->
<!--          <i class="el-icon-truck" style="font-size: 60px;color: #34bfa3"></i>-->
<!--        </div>-->
<!--        <div class="card-panel-description">-->
<!--          <div class="card-panel-text">-->
<!--            配送计划-->
<!--          </div>-->
<!--          <count-to :start-val="0" :end-val="syData.jrps" :duration="3600" class="card-panel-num" />-->
<!--        </div>-->
<!--      </div>-->
<!--    </el-col>-->
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
import { mainListRukuInfo } from "@/api/business/rukuInfo";
import { mainListChukuInfo } from "@/api/business/chukuInfo";
import { mainListNcDistributionPlan } from "@/api/business/ncDistributionPlan";
import {
  listSalesorder
} from "@/api/sales/salesorder";

export default {
  components: {
    CountTo
  },
  data(){
    return {
      syData:{
        jrrk:null,
        jrck:null,
        jrpc:null,
        jrps:null
      },
      queryParams1:{
        pageNum: 1,
        pageSize: 10,
      },
      queryParams2:{
        pageNum: 1,
        pageSize: 10,
      },
      // queryParams3:{
      //   pageNum: 1,
      //   pageSize: 10,
      // },
      queryParams4:{
        pageNum: 1,
        pageSize: 10,
        queryParam3:0,
      },
      queryParams3: {
        pageNum: 1,
        pageSize: 10,
        isDel: "0",
        state: "0",
      },
    }
  },
  created() {
    let currentDate = new Date();
    let year = currentDate.getFullYear(); // 获取当前年份
    let month = currentDate.getMonth() + 1; // 获取当前月份，注意月份从0开始，所以要加1
    let day = currentDate.getDate();
    let nowDate = year+'-'+month+'-'+day
    this.queryParams1.rukuDate = nowDate
    this.queryParams2.chukuDate = nowDate
    // this.queryParams3.chukuDate = nowDate
    // this.queryParams4.chukuDate = nowDate
    mainListRukuInfo(this.queryParams1).then(res=>{
      this.syData.jrrk = res.total
    })
    mainListChukuInfo(this.queryParams2).then(res=>{
      this.syData.jrck = res.total
    })
    mainListNcDistributionPlan(this.queryParams4).then(res=>{
      this.syData.jrps = res.total
    })
    listSalesorder(this.queryParams3).then(response => {
      this.syData.jrpc = response.total;
    });
  },
  methods: {
    handleSetLineChartData(type) {
      let that = this
      // 开启延时器，200ms的间隔用来区分单击和双击，解决双击时执行两次单击事件
      clearTimeout(that.time)
      that.time = setTimeout(() => {
        this.$router.push({path:type})
      },200)
    },
    dbclick() {
      clearTimeout(this.time)
      // 双击事件 不写不执行，禁用
    },
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;

  }

  .card-panel {
    height: 120px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);
    border-radius: 10px;
    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
